<?php
	class CompanyreviewAction extends Action {
		
		public function __construct() {
			parent::__construct();
			if(!empty($_GET['cid'])){
				$_SESSION['company']['cid'] = $_GET['cid'];
			}
			$this->assign('cid',$_SESSION['company']['cid']);
		}
	
		public function index(){
			if($_GET['cid']!=""){
				$cid = $_GET['cid'];
			}else{
				$cid = $_SESSION['company']['cid'];
			}
			$diyinfo = D('Company')->get_company_style($cid);
			$this->assign('diyinfo',$diyinfo);
			$this->display();
		}
		public function company_info(){
            $cid = $_GET['cid'];
			$info = D('Company')->get_company_info($cid);
            $this->assign('info',$info);
            $this->display();
        }
        public function contect_us(){
            $cid = $_GET['cid'];
			$info = D('Company')->get_company_info($cid);
            $this->assign('info',$info);
            $this->display();
        }
		public function hot_hiring(){
			$cid = $_SESSION['company']['cid'];
			$hot_hiring = D('Company')->get_hot_hiring_list($cid);
			$this->assign('hot_hiring',$hot_hiring);
			$this->display();
		}
		public function mess_list(){
        	$uid = $_SESSION['member']['uid'];
        	$in = D('member_info')->where(array('uid'=>$uid))->find();
        	if($in['truename'] == ""){
        		$this->assign('tid',1);
        	}else{
        		$this->assign('truename',$in['truename']);
        	}
        	$cid = $_GET['cid'];
			$mess = D('Company')->get_company_message($cid);
            $this->assign('mess',$mess);
            $this->display();
        }

        public function add_mess(){
        	$data['from'] = $_POST['from'];
        	$data['to'] = $_POST['cid'];
        	$data['content'] = $_POST['content'];
        	$data['ctime'] = time();
        	$result = D('message')->add($data);
        	if($result){
        		$this->success('成功！');
        	}else{
        		$this->success('失败！');
        	}
        }
		
		public function hiring_show(){
			$hid = $_GET['hiring_id'];
			$list = D('Hiring')->hiring_show($hid);
			$this->assign('list',$list);
			$this->assign('workplace',format_workplace($list['store']));
			$this->assign('compic',$list['com_pic']);
			$this->display();
		}

		public function send_resume(){
			$map['uid'] = $_SESSION['member']['uid'];
			$map['is_del'] = 0;
			$member = D('member_info')->where($map)->find();
			$resume = D('resume')->where($map)->find();
			if(empty($member)){
				redirect(U('Resume/resume'));
				return false;
			}else{
				if($member['truename']=="" || $member['phone']=="" || $member['xingbie']=="" || $member['shengri']=="" || $member['mypic']==""){
					redirect(U('Resume/resume_01'));
					return false;
				}
			}
			if(empty($resume)){
				redirect(U('Resume/resume_02'));
				return false;
			}
			$data['hiring_id'] = $_POST['hiring_id'];
			$data['resume_id'] = $resume['resume_id'];
			$data['send_time'] = time();
			$data['from'] = 2;
			/*print_r($data);
			return false;*/
			$result = D('send_resume')->add($data);
			if($result){
				$this->ajaxReturn('','success',1);
			}else{
				$this->ajaxReturn('','error',0);
			}
		}
	
	
	}
?>